package user.action;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import mvc.action.BaseAction;
import mvc.form.BaseForm;
import user.form.LoginForm;

public class LoginAction implements BaseAction {

	@Override
	public String execute(HttpServletRequest request, BaseForm form, Map<String, String> actionForward) {
		LoginForm loginForm = (LoginForm) form;
		String name = loginForm.getUsername();
		String pwd = loginForm.getUserpwd();
		String url = "error";
		if ("admin".equals(name) && "123".equals(pwd)) {
			request.setAttribute("success", "登陆成功！");
			url = "success";
		} else {
			request.setAttribute("error", "登陆失败！");
		}
		return actionForward.get(url);
	}
}
